﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using App;
using Autodesk.Revit.DB;
using DwgPreviewLib;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using HYPretreatmentModeling.SpraySystemReBuild.ReadSpraySystemDWGData;
using HYPretreatmentModeling.SpraySystemReBuild.ReadSpraySystemDWGData.CADPipeExport;
using HYRevitCode.FormUtility;
using HYRevitCode.RevitObjectCompareUtility;
using YJKRGeometry;
using Teigha.Core;
using Teigha.TD;

namespace ReadPipeDWGInfo
{
	public partial class ReadPipeDWGDataSettingForm : System.Windows.Forms.Form
	{
		public static bool b
		{
			set
			{
				ReadPipeDWGDataSettingForm.m_b = value;
			}
		}

		public bool IsLinkDWG
		{
			get
			{
				return this.m_isLinkDWG;
			}
			set
			{
				this.m_isLinkDWG = value;
			}
		}

		public FrmDefineSprayPipeDiameter FrmDefineSprayPipeDiameter
		{
			get
			{
				return this.m_frmDefineSprayPipeDiameter;
			}
			set
			{
				this.m_frmDefineSprayPipeDiameter = value;
			}
		}

		public static OdDbDatabase ThisDatabase
		{
			get
			{
				return ReadPipeDWGDataSettingForm.m_database;
			}
			set
			{
				ReadPipeDWGDataSettingForm.m_database = value;
			}
		}

		public ReadPipeDWGDataSettingForm(Autodesk.Revit.DB.Document doc, string OdDbDataBasePath)
		{
			ReadPipeDWGDataSettingForm.m_database = null;
			this.InitializeComponent();
			this.m_doc = doc;
			this.m_OdDbDataBasePath = OdDbDataBasePath;
			this.useXYZComparer.SetPrecision(0u);
			ReadPipeDWGDataSettingForm.m_database = TeighaServices.TeighaServicesInstance.HostAppServices.readFile(this.m_OdDbDataBasePath);
			if (!ReadPipeDWGDataSettingForm.m_b)
			{
				this.DeleteViews(this.tblLayoutPanelDWG);
				this.CreateViews(this.m_OdDbDataBasePath, this.tblLayoutPanelDWG);
			}
		}

		private void ReadPipeDWGDataSettingForm_Load(object sender, EventArgs e)
		{
			this.m_isLinkDWG = true;
			base.Icon = Resource.YArchitechIcon;
			this.txtMarkedTextPipeMaxDistance.Text = "100";
			this.btnStartPt.Enabled = false;
			this.btnMainPipeSelection.Enabled = false;
			this.lblInputText.Text = string.Empty;
			this.AddControlGroup();
			this.m_ControlInfoManager = new ControlInfoManager(this, this.m_lstControlGroup, null, null);
			this.m_ControlInfoManager.SetControlInfoToForm();
			if (this.pbxWH.Tag != null && this.pbxWH.Tag.ToString() != string.Empty)
			{
				string[] array = this.pbxWH.Tag.ToString().Split(new char[]
				{
					','
				});
				this.m_nWidth = Convert.ToInt32(array[0]);
				this.m_nHeight = Convert.ToInt32(array[1]);
			}
			else
			{
				this.m_nWidth = Convert.ToInt32(base.Width);
				this.m_nHeight = Convert.ToInt32(base.Height);
			}
			if (this.pbxWHNew.Tag != null && this.pbxWHNew.Tag.ToString() != string.Empty)
			{
				string[] array2 = this.pbxWHNew.Tag.ToString().Split(new char[]
				{
					','
				});
				base.Width = Convert.ToInt32(array2[0]);
				base.Height = Convert.ToInt32(array2[1]);
			}
			this.MinimumSize = new Size(Convert.ToInt32((double)this.m_nWidth * this.m_dWCoefficient), Convert.ToInt32((double)this.m_nHeight * this.m_dHCoefficient));
			if (this.rdoByTwoLine.Checked && this.pBxPickTwoLine.Tag != null && this.pBxPickTwoLine.Tag.ToString() != string.Empty)
			{
				this.m_strPipeLine = this.pBxPickTwoLine.Tag.ToString();
				this.pBxPickTwoLine.Image = Resources.GreenCheck;
			}
			if (this.rdoByPickPoint.Checked && this.pbxStartPt.Tag != null && this.pbxStartPt.Tag.ToString() != string.Empty)
			{
				this.m_strPipeStart = this.pbxStartPt.Tag.ToString();
				this.pbxStartPt.Image = Resources.GreenCheck;
			}
			if (this.pbxPickPipe.Tag != null && this.pbxPickPipe.Tag.ToString() != string.Empty)
			{
				this.m_strPipeLayer = this.pbxPickPipe.Tag.ToString();
				this.pbxPickPipe.Image = Resources.GreenCheck;
			}
			if (this.pbxPickUpperSprayer.Tag != null && this.pbxPickUpperSprayer.Tag.ToString() != string.Empty)
			{
				this.m_strUpNozzle = this.pbxPickUpperSprayer.Tag.ToString();
				this.pbxPickUpperSprayer.Image = Resources.GreenCheck;
			}
			if (this.pbxPickLowerSprayer.Tag != null && this.pbxPickLowerSprayer.Tag.ToString() != string.Empty)
			{
				this.m_strLowNozzle = this.pbxPickLowerSprayer.Tag.ToString();
				this.pbxPickLowerSprayer.Image = Resources.GreenCheck;
			}
			if (this.rdoTextLayer.Checked && this.pbxPickPipeSizeMarkedText.Tag != null && this.pbxPickPipeSizeMarkedText.Tag.ToString() != string.Empty)
			{
				this.m_strDimLayer = this.pbxPickPipeSizeMarkedText.Tag.ToString();
				this.pbxPickPipeSizeMarkedText.Image = Resources.GreenCheck;
			}
			if (this.rdoDefineDiameter.Checked && this.pbxMainPipeSelection.Tag != null && this.pbxMainPipeSelection.Tag.ToString() != string.Empty)
			{
				this.pbxMainPipeSelection.Image = Resources.GreenCheck;
			}
		}

		public void DeleteViews(TableLayoutPanel tableLayoutPanel)
		{
			tableLayoutPanel.Controls.Clear();
		}

		private void CreateViews(string OdDbDataBasePath, TableLayoutPanel tableLayoutPanel)
		{
			this.m_view = new DwgPreview();
			this.m_view.SetFilePath(OdDbDataBasePath);
			this.m_view.RefreshView();
			this.m_view.Dock = DockStyle.Fill;
			this.m_view.Margin = new Padding(1);
			tableLayoutPanel.Controls.Add(this.m_view);
		}

		protected override void OnClosed(EventArgs e)
		{
			this.m_ControlInfoManager.GetControlInfoToXml();
			this.m_view.DisposeAll();
		}

		public void InitBlockFrame()
		{
			using (this.m_view._hDevice.viewAt(0))
			{
				this.m_view.Invalidate();
			}
		}

		private void btnPickPipe_Click(object sender, EventArgs e)
		{
			if (this.m_layerTR != null)
			{
				DwgPreview.SetOffLayer(this.m_layerTR, false);
			}
			this.btnPickPipe.Enabled = false;
			this.m_dbPipeEntity = null;
			for (;;)
			{
				this.lblInputText.Text = "请点选管道图层";
				if (this.m_view.pickElement(ref this.m_dbPipeEntity) != DwgPreview.EUiStatus.eOk)
				{
					break;
				}
				if (this.m_dbPipeEntity != null)
				{
					goto Block_3;
				}
			}
			this.lblInputText.Text = string.Empty;
			this.btnPickPipe.Enabled = true;
			return;
			Block_3:
			this.lblInputText.Text = "点选的管道图层为：" + this.m_dbPipeEntity.layer();
			this.btnPickPipe.Enabled = true;
			this.m_strPipeLayer = this.m_dbPipeEntity.layer();
			this.pbxPickPipe.Image = Resources.GreenCheck;
			this.pbxPickPipe.Tag = this.m_strPipeLayer;
			DwgPreview.SetOffLayer(this.m_dbPipeEntity, true);
			this.m_layerTR = this.m_dbPipeEntity;
		}

		private void btnPickUpperSprayer_Click(object sender, EventArgs e)
		{
			if (this.m_layerTR != null)
			{
				DwgPreview.SetOffLayer(this.m_layerTR, false);
			}
			this.btnPickUpperSprayer.Enabled = false;
			this.m_dbUpperSprayerEntity = null;
			for (;;)
			{
				this.lblInputText.Text = "请点选上喷头图层";
				if (this.m_view.pickElement(ref this.m_dbUpperSprayerEntity) != DwgPreview.EUiStatus.eOk)
				{
					break;
				}
				if (this.m_dbUpperSprayerEntity != null)
				{
					goto Block_3;
				}
			}
			this.lblInputText.Text = string.Empty;
			this.btnPickUpperSprayer.Enabled = true;
			return;
			Block_3:
			this.lblInputText.Text = "选择的上喷喷头：" + this.m_dbUpperSprayerEntity.layer();
			this.btnPickUpperSprayer.Enabled = true;
			this.m_strUpNozzle = this.m_dbUpperSprayerEntity.layer();
			this.pbxPickUpperSprayer.Image = Resources.GreenCheck;
			this.pbxPickUpperSprayer.Tag = this.m_strUpNozzle;
			DwgPreview.SetOffLayer(this.m_dbUpperSprayerEntity, true);
			this.m_layerTR = this.m_dbUpperSprayerEntity;
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			if (this.JudgeSettingValue())
			{
				base.DialogResult = DialogResult.OK;
				PipeCADElement.m_nNowCanUseIndex = 0;
			}
		}

		internal CADData GetCADData()
		{
			if (this.m_strUpNozzle != string.Empty)
			{
				this.m_CADData.IsUpperStrEmpty = true;
			}
			else
			{
				this.m_CADData.IsUpperStrEmpty = false;
			}
			if (this.m_strLowNozzle != string.Empty)
			{
				this.m_CADData.IsLowerStrEmpty = true;
			}
			else
			{
				this.m_CADData.IsLowerStrEmpty = false;
			}
			if (this.m_BasePoint != null)
			{
				this.m_CADData.StratPt = this.m_BasePoint;
			}
			else if (this.rdoByTwoLine.Checked)
			{
				this.m_CADData.StratPt = this.GetPtByTextBox(this.m_strPipeLine);
			}
			else
			{
				this.m_CADData.StratPt = this.GetPtByTextBox(this.m_strPipeStart);
			}
			this.m_CADData.StrMarkedTextPipeMaxDistance = this.txtMarkedTextPipeMaxDistance.Text;
			OdResBuf odResBuf = OdResBuf.newRb(0, "LWPOLYLINE");
			odResBuf.setNext(OdResBuf.newRb(8, this.m_strPipeLayer));
			OdDbObjectIdArray odDbObjectIdArray = OdDbSelectionSet.select(ReadPipeDWGDataSettingForm.m_database, odResBuf).objectIdArray();
			OdResBuf odResBuf2 = OdResBuf.newRb(0, "LINE");
			odResBuf2.setNext(OdResBuf.newRb(8, this.m_strPipeLayer));
			OdDbObjectIdArray odDbObjectIdArray2 = OdDbSelectionSet.select(ReadPipeDWGDataSettingForm.m_database, odResBuf2).objectIdArray();
			if (odDbObjectIdArray.Count != 0)
			{
				this.ReadPipeLayer(odDbObjectIdArray, "LWPOLYLINE");
			}
			if (odDbObjectIdArray2.Count != 0)
			{
				this.ReadPipeLayer(odDbObjectIdArray2, "LINE");
			}
			if (odDbObjectIdArray.Count == 0 && odDbObjectIdArray2.Count == 0)
			{
				odDbObjectIdArray = this.GetSelectObjectIdArray("LWPOLYLINE", this.m_strPipeLayer);
				odDbObjectIdArray2 = this.GetSelectObjectIdArray("LINE", this.m_strPipeLayer);
				if (odDbObjectIdArray.Count != 0)
				{
					this.ReadPipeLayer(odDbObjectIdArray, "LWPOLYLINE");
				}
				else if (odDbObjectIdArray2.Count != 0)
				{
					this.ReadPipeLayer(odDbObjectIdArray2, "LINE");
				}
			}
			if (this.rdoTextLayer.Checked)
			{
				this.m_CADData.IsTextLayer = this.rdoTextLayer.Checked;
				this.m_CADData.IsDefineDiameter = this.rdoDefineDiameter.Checked;
				OdResBuf odResBuf3 = OdResBuf.newRb(0, "TEXT");
				odResBuf3.setNext(OdResBuf.newRb(8, this.m_strDimLayer));
				OdDbObjectIdArray odDbObjectIdArray3 = OdDbSelectionSet.select(ReadPipeDWGDataSettingForm.m_database, odResBuf3).objectIdArray();
				if (odDbObjectIdArray3.Count == 0)
				{
					odDbObjectIdArray3 = this.GetSelectObjectIdArray("TEXT", this.m_strDimLayer);
				}
				if (odDbObjectIdArray3.Count == 0)
				{
					return this.m_CADData;
				}
				OdDbText odDbText = (OdDbText)odDbObjectIdArray3[0].openObject(OpenMode.kForRead);
				this.m_CADData.PipeTextHeight = odDbText.height();
				OdDbText odDbText2 = (OdDbText)odDbText.clone();
				odDbText2.setRotation(0.0);
				OdGeExtents3d odGeExtents3d = new OdGeExtents3d();
				odDbText2.getGeomExtents(odGeExtents3d);
				OdGePoint3d odGePoint3d = odGeExtents3d.maxPoint();
				OdGePoint3d odGePoint3d2 = odGeExtents3d.minPoint();
				double pipeTextLength = Math.Abs(odGePoint3d.x - odGePoint3d2.x);
				this.m_CADData.PipeTextLength = pipeTextLength;
				foreach (OdDbObjectId odDbObjectId in odDbObjectIdArray3)
				{
					OdDbText odDbText3 = (OdDbText)odDbObjectId.openObject(OpenMode.kForRead);
					string strPipeText = odDbText3.textString();
					double num = 0.0;
					if (this.GetPipeRadius(strPipeText, out num) && 10.0 < num && num <= 500.0)
					{
						double pipeDiameterTextRotationAngle = odDbText3.rotation() * 57.295779513082323;
						OdGePoint3d odGePoint3d3 = odDbText3.position();
						XYZ pipeDiameterTextLocation = new XYZ(odGePoint3d3.x, odGePoint3d3.y, odGePoint3d3.z);
						PipeDiameterTextCADElement pipeDiameterTextCADElement = new PipeDiameterTextCADElement();
						pipeDiameterTextCADElement.TextPipeRadius = num;
						OdGeExtents3d odGeExtents3d2 = new OdGeExtents3d();
						odDbText3.getGeomExtents(odGeExtents3d2);
						pipeDiameterTextCADElement.CenterLocation = new XYZ(odGeExtents3d2.center().x, odGeExtents3d2.center().y, odGeExtents3d2.center().z);
						pipeDiameterTextCADElement.PipeDiameterTextRotationAngle = pipeDiameterTextRotationAngle;
						pipeDiameterTextCADElement.PipeDiameterTextLocation = pipeDiameterTextLocation;
						this.m_CADData.LstAllPipeDiameterText.Add(pipeDiameterTextCADElement);
					}
				}
			}
			string text = this.JudgeSprayLayerType();
			if (text != null)
			{
				if (this.m_strUpNozzle != string.Empty && this.m_strLowNozzle != string.Empty && this.m_strUpNozzle == this.m_strLowNozzle)
				{
					ReadPipeDWGDataSettingForm.m_GetmNozzleLayerType = EnumGetNozzleLayerType.TwoAndSame;
					this.ReadSprayerEntityLayerInfo(text, this.m_strUpNozzle);
				}
				else if (this.m_strUpNozzle != string.Empty && this.m_strLowNozzle != string.Empty && this.m_strUpNozzle != this.m_strLowNozzle)
				{
					ReadPipeDWGDataSettingForm.m_GetmNozzleLayerType = EnumGetNozzleLayerType.TwoAndNoSame;
					this.ReadSprayerEntityLayerInfo(text, this.m_strUpNozzle);
					this.ReadSprayerEntityLayerInfo(text, this.m_strLowNozzle);
				}
				else if (this.m_strUpNozzle != string.Empty && this.m_strLowNozzle == string.Empty)
				{
					ReadPipeDWGDataSettingForm.m_GetmNozzleLayerType = EnumGetNozzleLayerType.HaveUpperNoLower;
					this.ReadSprayerEntityLayerInfo(text, this.m_strUpNozzle);
				}
				else if (this.m_strUpNozzle == string.Empty && this.m_strLowNozzle != string.Empty)
				{
					ReadPipeDWGDataSettingForm.m_GetmNozzleLayerType = EnumGetNozzleLayerType.HaveLowerNoUpper;
					this.ReadSprayerEntityLayerInfo(text, this.m_strLowNozzle);
				}
				else if (this.m_strUpNozzle == string.Empty && this.m_strLowNozzle == string.Empty)
				{
					ReadPipeDWGDataSettingForm.m_GetmNozzleLayerType = EnumGetNozzleLayerType.NOUpperAndLower;
				}
			}
			return this.m_CADData;
		}

		private OdDbObjectIdArray GetSelectObjectIdArray(string strEntityType, string strSelectLayerName)
		{
			OdResBuf pFilter = OdResBuf.newRb(0, strEntityType);
			OdDbObjectIdArray odDbObjectIdArray = OdDbSelectionSet.select(ReadPipeDWGDataSettingForm.m_database, pFilter).objectIdArray();
			OdDbObjectIdArray odDbObjectIdArray2 = new OdDbObjectIdArray();
			foreach (OdDbObjectId odDbObjectId in odDbObjectIdArray)
			{
				if ((odDbObjectId.openObject(OpenMode.kForRead) as OdDbEntity).layer().Contains(strSelectLayerName))
				{
					odDbObjectIdArray2.Add(odDbObjectId);
				}
			}
			return odDbObjectIdArray2;
		}

		private XYZ GetPtByTextBox(string strTextBox)
		{
			XYZ result = null;
			if (strTextBox != string.Empty)
			{
				string[] array = strTextBox.Split(new char[]
				{
					','
				});
				if (this.IsNumberic(array))
				{
					result = new XYZ(Convert.ToDouble(array[0]), Convert.ToDouble(array[1]), Convert.ToDouble(array[2]));
				}
			}
			return result;
		}

		private bool IsNumberic(string[] arText)
		{
			bool result;
			try
			{
				for (int i = 0; i < arText.Length; i++)
				{
					Convert.ToDouble(arText[i]);
				}
				result = true;
			}
			catch
			{
				result = false;
			}
			return result;
		}

		private void ReadPipeLayer(OdDbObjectIdArray arPipeLayerIds, string strPipeLayerType)
		{
			if (strPipeLayerType == "LWPOLYLINE")
			{
				using (OdDbObjectIdArray.OdDbObjectIdArrayEnumerator enumerator = arPipeLayerIds.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						OdDbObjectId odDbObjectId = enumerator.Current;
						OdDbPolyline odDbPolyline = (OdDbPolyline)odDbObjectId.openObject(OpenMode.kForRead);
						OdGePoint3d odGePoint3d = new OdGePoint3d();
						OdGePoint3d odGePoint3d2 = new OdGePoint3d();
						XYZ xyz = new XYZ();
						XYZ xyz2 = new XYZ();
						uint num = odDbPolyline.numVerts();
						if (num == 2u)
						{
							odDbPolyline.getPointAt(0u, odGePoint3d);
							odDbPolyline.getPointAt(1u, odGePoint3d2);
							xyz = new XYZ(odGePoint3d.x, odGePoint3d.y, XYZ.Zero.Z);
							xyz2 = new XYZ(odGePoint3d2.x, odGePoint3d2.y, XYZ.Zero.Z);
							if (this.useXYZComparer.GetHashCode(xyz) != this.useXYZComparer.GetHashCode(xyz2) && xyz.DistanceTo(xyz2) > this.m_doc.Application.ShortCurveTolerance)
							{
								PipeCADElement pipeCADElement = new PipeCADElement(xyz, xyz2);
								if (this.IsContainsObjectId(odDbObjectId))
								{
									pipeCADElement.BIsMainPipe = true;
								}
								this.m_CADData.LstAllPipe.Add(pipeCADElement);
							}
						}
						else
						{
							uint num2 = 0u;
							while (num2 < num && num2 + 1u < num)
							{
								odDbPolyline.getPointAt(num2, odGePoint3d);
								odDbPolyline.getPointAt(num2 + 1u, odGePoint3d2);
								xyz = new XYZ(odGePoint3d.x, odGePoint3d.y, XYZ.Zero.Z);
								xyz2 = new XYZ(odGePoint3d2.x, odGePoint3d2.y, XYZ.Zero.Z);
								if (this.useXYZComparer.GetHashCode(xyz) != this.useXYZComparer.GetHashCode(xyz2) && xyz.DistanceTo(xyz2) > this.m_doc.Application.ShortCurveTolerance)
								{
									PipeCADElement pipeCADElement2 = new PipeCADElement(xyz, xyz2);
									if (this.IsContainsObjectId(odDbObjectId))
									{
										pipeCADElement2.BIsMainPipe = true;
									}
									this.m_CADData.LstAllPipe.Add(pipeCADElement2);
								}
								num2 += 1u;
							}
						}
					}
					return;
				}
			}
			if (strPipeLayerType == "LINE")
			{
				foreach (OdDbObjectId odDbObjectId2 in arPipeLayerIds)
				{
					OdDbLine odDbLine = (OdDbLine)odDbObjectId2.openObject(OpenMode.kForRead);
					OdGePoint3d odGePoint3d3 = new OdGePoint3d();
					OdGePoint3d odGePoint3d4 = new OdGePoint3d();
					XYZ xyz3 = new XYZ();
					XYZ xyz4 = new XYZ();
					odDbLine.getStartPoint(odGePoint3d3);
					odDbLine.getEndPoint(odGePoint3d4);
					xyz3 = new XYZ(odGePoint3d3.x, odGePoint3d3.y, XYZ.Zero.Z);
					xyz4 = new XYZ(odGePoint3d4.x, odGePoint3d4.y, XYZ.Zero.Z);
					if (this.useXYZComparer.GetHashCode(xyz3) != this.useXYZComparer.GetHashCode(xyz4) && xyz3.DistanceTo(xyz4) > this.m_doc.Application.ShortCurveTolerance)
					{
						PipeCADElement pipeCADElement3 = new PipeCADElement(xyz3, xyz4);
						if (this.IsContainsObjectId(odDbObjectId2))
						{
							pipeCADElement3.BIsMainPipe = true;
						}
						this.m_CADData.LstAllPipe.Add(pipeCADElement3);
					}
				}
			}
		}

		private string JudgeSprayLayerType()
		{
			if (this.m_strUpNozzle != string.Empty)
			{
				OdResBuf odResBuf = OdResBuf.newRb(0, "insert");
				odResBuf.setNext(OdResBuf.newRb(8, this.m_strUpNozzle));
				OdDbObjectIdArray odDbObjectIdArray = OdDbSelectionSet.select(ReadPipeDWGDataSettingForm.m_database, odResBuf).objectIdArray();
				OdResBuf odResBuf2 = OdResBuf.newRb(0, "Circle");
				odResBuf2.setNext(OdResBuf.newRb(8, this.m_strUpNozzle));
				OdDbObjectIdArray odDbObjectIdArray2 = OdDbSelectionSet.select(ReadPipeDWGDataSettingForm.m_database, odResBuf2).objectIdArray();
				if (odDbObjectIdArray.Count != 0)
				{
					return "insert";
				}
				if (odDbObjectIdArray2.Count != 0)
				{
					return "Circle";
				}
				OdDbObjectIdArray selectObjectIdArray = this.GetSelectObjectIdArray("insert", this.m_strUpNozzle);
				odDbObjectIdArray2 = this.GetSelectObjectIdArray("Circle", this.m_strUpNozzle);
				if (selectObjectIdArray.Count != 0)
				{
					return "insert";
				}
				if (odDbObjectIdArray2.Count != 0)
				{
					return "Circle";
				}
				return null;
			}
			else
			{
				if (!(this.m_strLowNozzle != string.Empty))
				{
					ReadPipeDWGDataSettingForm.m_GetmNozzleLayerType = EnumGetNozzleLayerType.NOUpperAndLower;
					return null;
				}
				OdResBuf odResBuf3 = OdResBuf.newRb(0, "insert");
				odResBuf3.setNext(OdResBuf.newRb(8, this.m_strLowNozzle));
				OdDbObjectIdArray odDbObjectIdArray3 = OdDbSelectionSet.select(ReadPipeDWGDataSettingForm.m_database, odResBuf3).objectIdArray();
				OdResBuf odResBuf4 = OdResBuf.newRb(0, "Circle");
				odResBuf4.setNext(OdResBuf.newRb(8, this.m_strLowNozzle));
				OdDbObjectIdArray odDbObjectIdArray4 = OdDbSelectionSet.select(ReadPipeDWGDataSettingForm.m_database, odResBuf4).objectIdArray();
				if (odDbObjectIdArray3.Count != 0)
				{
					return "insert";
				}
				if (odDbObjectIdArray4.Count != 0)
				{
					return "Circle";
				}
				OdDbObjectIdArray selectObjectIdArray2 = this.GetSelectObjectIdArray("insert", this.m_strLowNozzle);
				odDbObjectIdArray4 = this.GetSelectObjectIdArray("Circle", this.m_strLowNozzle);
				if (selectObjectIdArray2.Count != 0)
				{
					return "insert";
				}
				if (odDbObjectIdArray4.Count != 0)
				{
					return "Circle";
				}
				return null;
			}
		}

		private bool JudgeSettingValue()
		{
			bool flag = true;
			if (this.rdoByPickPoint.Checked)
			{
				if (this.m_strPipeStart == string.Empty)
				{
					flag = false;
				}
				if (!flag)
				{
					return flag;
				}
			}
			else
			{
				if (this.m_strPipeLine == string.Empty)
				{
					flag = false;
				}
				if (!flag)
				{
					return flag;
				}
			}
			flag = this.GetTextValue(this.m_strPipeLayer, "管道图层");
			if (!flag)
			{
				return flag;
			}
			if (this.rdoTextLayer.Checked)
			{
				flag = this.GetTextValue(this.m_strDimLayer, "管径标注图层");
				if (!flag)
				{
					return flag;
				}
			}
			if (this.rdoDefineDiameter.Checked && this.m_lstMainPipeSelectionObjectId.Count == 0)
			{
				YJKMessageBox.Warning("请点选主入口管道图层(可多次点选)");
				return false;
			}
			if (this.rdoDefineDiameter.Checked && this.FrmDefineSprayPipeDiameter == null)
			{
				YJKMessageBox.Warning("请设置管径信息");
				return false;
			}
			if (this.rdoDefineDiameter.Checked && this.m_strUpNozzle == string.Empty && this.m_strLowNozzle == string.Empty)
			{
				YJKMessageBox.Warning("若不生成喷淋喷头，则定管径方式不可用");
				return false;
			}
			return flag;
		}

		private bool GetTextValue(string strContent, string strText)
		{
			bool result = true;
			if (strContent == string.Empty)
			{
				YJKMessageBox.Warning(string.Format("{0}不能为空！", strText));
				return false;
			}
			return result;
		}

		private void ReadSprayerEntityLayerInfo(string strSprayerLayerType, string strSprayerLayerName)
		{
			OdResBuf odResBuf = OdResBuf.newRb(0, strSprayerLayerType);
			odResBuf.setNext(OdResBuf.newRb(8, strSprayerLayerName));
			OdDbObjectIdArray odDbObjectIdArray = OdDbSelectionSet.select(ReadPipeDWGDataSettingForm.m_database, odResBuf).objectIdArray();
			if (odDbObjectIdArray.Count == 0)
			{
				odDbObjectIdArray = this.GetSelectObjectIdArray(strSprayerLayerType, strSprayerLayerName);
			}
			if (strSprayerLayerType == "insert")
			{
				using (OdDbObjectIdArray.OdDbObjectIdArrayEnumerator enumerator = odDbObjectIdArray.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						OdDbObjectId odDbObjectId = enumerator.Current;
						OdDbBlockReference odDbBlockReference = (OdDbBlockReference)odDbObjectId.openObject(OpenMode.kForRead);
						OdDbBlockTableRecord odDbBlockTableRecord = (OdDbBlockTableRecord)odDbBlockReference.blockTableRecord().openObject();
						PipeSprayCADElement pipeSprayCADElement = new PipeSprayCADElement();
						OdDbBlockReference odDbBlockReference2 = (OdDbBlockReference)odDbBlockReference.clone();
						odDbBlockReference2.setRotation(0.0);
						OdGeExtents3d odGeExtents3d = new OdGeExtents3d();
						odDbBlockReference2.getGeomExtents(odGeExtents3d);
						OdGePoint3d odGePoint3d = odGeExtents3d.maxPoint();
						OdGePoint3d odGePoint3d2 = odGeExtents3d.minPoint();
						double sprayRadius = Math.Abs(odGePoint3d.x - odGePoint3d2.x) / 2.0;
						pipeSprayCADElement.SprayRadius = sprayRadius;
						pipeSprayCADElement.Location = new XYZ(odGeExtents3d.center().x, odGeExtents3d.center().y, XYZ.Zero.Z);
						if (ReadPipeDWGDataSettingForm.m_GetmNozzleLayerType != EnumGetNozzleLayerType.TwoAndSame)
						{
							if (this.m_strUpNozzle == strSprayerLayerName)
							{
								pipeSprayCADElement.ThisSprayKind = SprayKindEnum.Upper;
							}
							else if (this.m_strLowNozzle == strSprayerLayerName)
							{
								pipeSprayCADElement.ThisSprayKind = SprayKindEnum.Lower;
							}
						}
						this.m_CADData.LstAllPipeSpray.Add(pipeSprayCADElement);
					}
					return;
				}
			}
			if (strSprayerLayerType == "Circle")
			{
				foreach (OdDbObjectId odDbObjectId2 in odDbObjectIdArray)
				{
					OdDbCircle odDbCircle = (OdDbCircle)odDbObjectId2.openObject(OpenMode.kForRead);
					PipeSprayCADElement pipeSprayCADElement2 = new PipeSprayCADElement();
					double sprayRadius2 = odDbCircle.radius();
					pipeSprayCADElement2.SprayRadius = sprayRadius2;
					OdGePoint3d odGePoint3d3 = odDbCircle.center();
					XYZ location = new XYZ(odGePoint3d3.x, odGePoint3d3.y, odGePoint3d3.z);
					pipeSprayCADElement2.Location = location;
					if (ReadPipeDWGDataSettingForm.m_GetmNozzleLayerType != EnumGetNozzleLayerType.TwoAndSame)
					{
						if (this.m_strUpNozzle == strSprayerLayerName)
						{
							pipeSprayCADElement2.ThisSprayKind = SprayKindEnum.Upper;
						}
						else if (this.m_strLowNozzle == strSprayerLayerName)
						{
							pipeSprayCADElement2.ThisSprayKind = SprayKindEnum.Lower;
						}
					}
					this.m_CADData.LstAllPipeSpray.Add(pipeSprayCADElement2);
				}
			}
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			PipeCADElement.m_nNowCanUseIndex = 0;
			DwgPreview.m_uiStatus = DwgPreview.EUiStatus.eCancel;
			base.DialogResult = DialogResult.Cancel;
			base.Close();
		}

		private void btnStartPt_Click(object sender, EventArgs e)
		{
			if (this.m_layerTR != null)
			{
				DwgPreview.SetOffLayer(this.m_layerTR, false);
				this.m_layerTR = null;
			}
			this.lblInputText.Text = "请点取管道起点";
			this.btnStartPt.Enabled = false;
			this.rdoByTwoLine.Enabled = false;
			OdGePoint3d odPoint3d = null;
			if (this.m_view.PickPoint(ref odPoint3d) != DwgPreview.EUiStatus.eOk)
			{
				this.lblInputText.Text = string.Empty;
				this.btnStartPt.Enabled = true;
				this.rdoByTwoLine.Enabled = true;
				return;
			}
			this.m_BasePoint = this.Point3dToXYZ(odPoint3d);
			string strPipeStart = string.Format("{0}, {1}, {2}", Math.Round(this.m_BasePoint.X, 3), Math.Round(this.m_BasePoint.Y, 3), 0.0);
			this.m_strPipeStart = strPipeStart;
			this.btnStartPt.Enabled = true;
			this.rdoByTwoLine.Enabled = true;
			this.lblInputText.Text = "选取得管道起点：" + this.m_strPipeStart;
			this.pbxStartPt.Image = Resources.GreenCheck;
			this.pbxStartPt.Tag = this.m_strPipeStart;
		}

		private void btnPickTwoLine_Click(object sender, EventArgs e)
		{
			if (this.m_layerTR != null)
			{
				DwgPreview.SetOffLayer(this.m_layerTR, false);
				this.m_layerTR = null;
			}
			OdGsModel pModel = this.m_view._hDevice.createModel();
			OdGsView odGsView = this.m_view._hDevice.viewAt(0);
			if (this.m_lstCircleDrawable.Count != 0)
			{
				foreach (OdDbCircle sceneGraph in this.m_lstCircleDrawable)
				{
					odGsView.erase(sceneGraph);
				}
			}
			this.btnPickTwoLine.Enabled = false;
			this.rdoByPickPoint.Enabled = false;
			Line line = null;
			Line line2 = null;
			for (;;)
			{
				this.lblInputText.Text = "请选择第一根线";
				if (this.m_view.pickLineElement(ref line) != DwgPreview.EUiStatus.eOk)
				{
					break;
				}
				if (!(line != null))
				{
					if (line == null)
					{
						YJKMessageBox.Warning("无法识别当前拾取");
					}
				}
				else
				{
					for (;;)
					{
						this.lblInputText.Text = "请选择第二根线";
						if (this.m_view.pickLineElement(ref line2) != DwgPreview.EUiStatus.eOk)
						{
							goto Block_7;
						}
						if (line2 != null)
						{
							if (!this.IsSameLine(line, line2))
							{
								break;
							}
							YJKMessageBox.Warning("不能重复点选同一根线，请重新选择！");
						}
						else if (line2 == null)
						{
							YJKMessageBox.Warning("无法识别当前拾取");
						}
					}
					this.lblInputText.Text = string.Empty;
					bool flag = true;
					if (flag)
					{
						goto Block_11;
					}
				}
			}
			this.btnPickTwoLine.Enabled = true;
			this.rdoByPickPoint.Enabled = true;
			this.lblInputText.Text = string.Empty;
			return;
			Block_7:
			this.btnPickTwoLine.Enabled = true;
			this.rdoByPickPoint.Enabled = true;
			this.lblInputText.Text = string.Empty;
			return;
			Block_11:
			IntersectionResultArray intersectionResultArray;
			if ((int)line.Intersect(line2, out intersectionResultArray) == 8)
			{
				IntersectionResult intersectionResult = intersectionResultArray.get_Item(0);
				this.m_BasePoint = intersectionResult.XYZPoint;
			}
			else
			{
				line = this.GetRevitUnboundLine(line);
				line2 = this.GetRevitUnboundLine(line2);
				if (line.Intersect(line2, out intersectionResultArray) != 8)
				{
					YJKMessageBox.Error("未获取到交点");
					this.btnPickTwoLine.Enabled = true;
					this.rdoByPickPoint.Enabled = true;
					return;
				}
				IntersectionResult intersectionResult2 = intersectionResultArray.get_Item(0);
				this.m_BasePoint = intersectionResult2.XYZPoint;
			}
			if (this.m_BasePoint != null)
			{
				string strPipeLine = string.Format("{0},{1},{2}", Math.Round(this.m_BasePoint.X, 3), Math.Round(this.m_BasePoint.Y, 3), 0.0);
				this.m_strPipeLine = strPipeLine;
				this.lblInputText.Text = "选取得基点：" + this.m_strPipeLine;
				this.btnPickTwoLine.Enabled = true;
				this.rdoByPickPoint.Enabled = true;
			}
			OdDbCircle odDbCircle = OdDbCircle.createObject();
			odDbCircle.setCenter(this.XYZToPoint3d(this.m_BasePoint));
			double radius = 150.0;
			odDbCircle.setRadius(radius);
			OdDbCircle odDbCircle2 = OdDbCircle.cast(odDbCircle.clone());
			OdCmEntityColor odCmEntityColor = new OdCmEntityColor(byte.MaxValue, 0, 0);
			odDbCircle2.setColorIndex((ushort)odCmEntityColor.colorIndex());
			odDbCircle2.setLineWeight(LineWeight.kLnWt211);
			odGsView.add(odDbCircle2, pModel);
			this.m_lstCircleDrawable.Add(odDbCircle2);
			this.m_view.Invalidate();
			this.pBxPickTwoLine.Image = Resources.GreenCheck;
			this.pBxPickTwoLine.Tag = this.m_strPipeLine;
		}

		private Line GetRevitUnboundLine(Line line)
		{
			XYZ endPoint = line.GetEndPoint(0);
			XYZ endPoint2 = line.GetEndPoint(1);
			XYZ xyz = endPoint - endPoint2;
			xyz = xyz.Normalize();
			return Line.CreateUnbound(endPoint, xyz);
		}

		private OdGePoint3d XYZToPoint3d(XYZ pt)
		{
			return new OdGePoint3d(pt.X, pt.Y, pt.Z);
		}

		private XYZ Point3dToXYZ(OdGePoint3d odPoint3d)
		{
			return new XYZ(odPoint3d.x, odPoint3d.y, odPoint3d.z);
		}

		private bool IsSameLine(Line line1, Line line2)
		{
			return Geometry.IsEqual(line1.GetEndPoint(0), line2.GetEndPoint(0)) && Geometry.IsEqual(line1.GetEndPoint(1), line2.GetEndPoint(1));
		}

		private void btnPickLowerSprayer_Click(object sender, EventArgs e)
		{
			if (this.m_layerTR != null)
			{
				DwgPreview.SetOffLayer(this.m_layerTR, false);
			}
			this.btnPickLowerSprayer.Enabled = false;
			this.m_dbLowerSprayerEntity = null;
			for (;;)
			{
				this.lblInputText.Text = "请点选下喷头图层";
				if (this.m_view.pickElement(ref this.m_dbLowerSprayerEntity) != DwgPreview.EUiStatus.eOk)
				{
					break;
				}
				if (this.m_dbLowerSprayerEntity != null)
				{
					goto Block_3;
				}
			}
			this.lblInputText.Text = string.Empty;
			this.btnPickLowerSprayer.Enabled = true;
			return;
			Block_3:
			this.lblInputText.Text = "选取的下喷喷头：" + this.m_dbLowerSprayerEntity.layer();
			this.btnPickLowerSprayer.Enabled = true;
			this.m_strLowNozzle = this.m_dbLowerSprayerEntity.layer();
			this.pbxPickLowerSprayer.Image = Resources.GreenCheck;
			this.pbxPickLowerSprayer.Tag = this.m_strLowNozzle;
			DwgPreview.SetOffLayer(this.m_dbLowerSprayerEntity, true);
			this.m_layerTR = this.m_dbLowerSprayerEntity;
		}

		private void btnCleanAllInfo_Click(object sender, EventArgs e)
		{
			if (this.m_layerTR != null)
			{
				DwgPreview.SetOffLayer(this.m_layerTR, false);
				this.m_layerTR = null;
			}
			if (this.m_dbDimensionEntity != null)
			{
				DwgPreview.SetOffLayer(this.m_dbDimensionEntity, false);
				this.m_dbDimensionEntity = null;
			}
			if (this.m_dbUpperSprayerEntity != null)
			{
				DwgPreview.SetOffLayer(this.m_dbUpperSprayerEntity, false);
				this.m_dbUpperSprayerEntity = null;
			}
			if (this.m_dbLowerSprayerEntity != null)
			{
				DwgPreview.SetOffLayer(this.m_dbLowerSprayerEntity, false);
				this.m_dbLowerSprayerEntity = null;
			}
			if (this.pBxPickTwoLine.Tag != null && this.pBxPickTwoLine.Tag.ToString() != string.Empty)
			{
				OdGsView odGsView = this.m_view._hDevice.viewAt(0);
				if (this.m_lstCircleDrawable.Count != 0)
				{
					foreach (OdDbCircle sceneGraph in this.m_lstCircleDrawable)
					{
						odGsView.erase(sceneGraph);
					}
				}
				this.m_strPipeLine = string.Empty;
				this.pBxPickTwoLine.Tag = string.Empty;
				this.pBxPickTwoLine.Image = Resources.GrayCheck;
			}
			if (this.pbxStartPt.Tag != null && this.pbxStartPt.Tag.ToString() != string.Empty)
			{
				this.m_strPipeStart = string.Empty;
				this.pbxStartPt.Tag = string.Empty;
				this.pbxStartPt.Image = Resources.GrayCheck;
			}
			if (this.pbxPickPipe.Tag != null && this.pbxPickPipe.Tag.ToString() != string.Empty)
			{
				this.m_strPipeLayer = string.Empty;
				this.pbxPickPipe.Tag = string.Empty;
				this.pbxPickPipe.Image = Resources.GrayCheck;
			}
			if (this.pbxPickUpperSprayer.Tag != null && this.pbxPickUpperSprayer.Tag.ToString() != string.Empty)
			{
				this.m_strUpNozzle = string.Empty;
				this.pbxPickUpperSprayer.Tag = string.Empty;
				this.pbxPickUpperSprayer.Image = Resources.GrayCheck;
			}
			if (this.pbxPickLowerSprayer.Tag != null && this.pbxPickLowerSprayer.Tag.ToString() != string.Empty)
			{
				this.m_strLowNozzle = string.Empty;
				this.pbxPickLowerSprayer.Tag = string.Empty;
				this.pbxPickLowerSprayer.Image = Resources.GrayCheck;
			}
			if (this.pbxPickPipeSizeMarkedText.Tag != null && this.pbxPickPipeSizeMarkedText.Tag.ToString() != string.Empty)
			{
				this.m_strDimLayer = string.Empty;
				this.pbxPickPipeSizeMarkedText.Tag = string.Empty;
				this.pbxPickPipeSizeMarkedText.Image = Resources.GrayCheck;
			}
			if (this.pbxMainPipeSelection.Tag != null && this.pbxMainPipeSelection.Tag.ToString() != string.Empty)
			{
				this.pbxMainPipeSelection.Image = Resources.GrayCheck;
			}
			this.gbxDrawingPreview.Focus();
			this.m_view.Focus();
			this.m_view.Refresh();
		}

		private void chkLinkSelectDWGToRevit_CheckedChanged(object sender, EventArgs e)
		{
			this.m_isLinkDWG = this.chkLinkSelectDWGToRevit.Checked;
		}

		private void btnPickPipeSizeMarkedText_Click(object sender, EventArgs e)
		{
			if (this.m_layerTR != null)
			{
				DwgPreview.SetOffLayer(this.m_layerTR, false);
			}
			this.btnPickPipeSizeMarkedText.Enabled = false;
			this.rdoDefineDiameter.Enabled = false;
			this.m_dbDimensionEntity = null;
			for (;;)
			{
				this.lblInputText.Text = "请点选管径标注图层";
				if (this.m_view.pickElement(ref this.m_dbDimensionEntity) != DwgPreview.EUiStatus.eOk)
				{
					break;
				}
				if (this.m_dbDimensionEntity != null)
				{
					goto Block_3;
				}
			}
			this.lblInputText.Text = string.Empty;
			this.btnPickPipeSizeMarkedText.Enabled = true;
			this.rdoDefineDiameter.Enabled = true;
			return;
			Block_3:
			this.lblInputText.Text = "选取的管径标注图层：" + this.m_dbDimensionEntity.layer();
			this.btnPickPipeSizeMarkedText.Enabled = true;
			this.rdoDefineDiameter.Enabled = true;
			this.m_strDimLayer = this.m_dbDimensionEntity.layer();
			this.pbxPickPipeSizeMarkedText.Image = Resources.GreenCheck;
			this.pbxPickPipeSizeMarkedText.Tag = this.m_strDimLayer;
			DwgPreview.SetOffLayer(this.m_dbDimensionEntity, true);
		}

		private void btnSetUp_Click(object sender, EventArgs e)
		{
			if (this.m_layerTR != null)
			{
				DwgPreview.SetOffLayer(this.m_layerTR, false);
			}
			this.FrmDefineSprayPipeDiameter = new FrmDefineSprayPipeDiameter(this.m_doc);
			if (this.FrmDefineSprayPipeDiameter.ShowDialog() != DialogResult.OK)
			{
				this.FrmDefineSprayPipeDiameter = null;
			}
		}

		private void rdoTextLayer_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoTextLayer.Checked)
			{
				this.btnPickPipeSizeMarkedText.Enabled = true;
				this.txtMarkedTextPipeMaxDistance.Enabled = true;
				this.btnSetUp.Enabled = false;
				this.btnMainPipeSelection.Enabled = false;
			}
		}

		private void rdoDefineDiameter_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoDefineDiameter.Checked)
			{
				this.btnPickPipeSizeMarkedText.Enabled = false;
				this.txtMarkedTextPipeMaxDistance.Enabled = false;
				this.btnSetUp.Enabled = true;
				this.btnMainPipeSelection.Enabled = true;
			}
		}

		private void btnMainPipeSelection_Click(object sender, EventArgs e)
		{
			if (this.m_layerTR != null)
			{
				DwgPreview.SetOffLayer(this.m_layerTR, false);
			}
			this.lblInputText.Text = "选择完(可进行多选)请按ESC键退出";
			this.SetFormStatus(false);
			this.m_lstMainPipeSelectionObjectId.Clear();
			while (this.m_view.pickElements(ref this.m_lstMainPipeSelectionObjectId) == DwgPreview.EUiStatus.eOk)
			{
			}
			this.lblInputText.Text = string.Empty;
			this.SetFormStatus(true);
			this.pbxMainPipeSelection.Image = Resources.GreenCheck;
			this.pbxMainPipeSelection.Tag = this.m_lstMainPipeSelectionObjectId;
		}

		private void SetFormStatus(bool bSet)
		{
			this.btnPickPipe.Enabled = bSet;
			this.btnPickLowerSprayer.Enabled = bSet;
			this.btnPickUpperSprayer.Enabled = bSet;
			this.btnPickTwoLine.Enabled = bSet;
			this.btnStartPt.Enabled = bSet;
			this.btnCleanAllInfo.Enabled = bSet;
			this.btnCancel.Enabled = bSet;
			this.btnOK.Enabled = bSet;
			this.btnSetUp.Enabled = bSet;
			this.rdoDefineDiameter.Enabled = bSet;
			this.rdoTextLayer.Enabled = bSet;
			this.btnMainPipeSelection.Enabled = bSet;
		}

		private bool IsContainsObjectId(OdDbObjectId dbObjectId)
		{
			bool result = false;
			if (this.m_lstMainPipeSelectionObjectId.Count != 0)
			{
				foreach (OdDbObjectId odDbObjectId in this.m_lstMainPipeSelectionObjectId)
				{
					ulong num = dbObjectId.getHandle().ToUInt64();
					ulong num2 = odDbObjectId.getHandle().ToUInt64();
					if (num == num2)
					{
						result = true;
						break;
					}
				}
			}
			return result;
		}

		private void AddControlGroup()
		{
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.rdoTextLayer, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.txtMarkedTextPipeMaxDistance, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.rdoDefineDiameter, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.rdoByPickPoint, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.rdoByTwoLine, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pBxPickTwoLine, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxStartPt, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxPickPipe, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxPickLowerSprayer, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxPickUpperSprayer, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxPickPipeSizeMarkedText, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxMainPipeSelection, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxWH, false));
			this.m_lstControlGroup.Add(new KeyValuePair<System.Windows.Forms.Control, bool>(this.pbxWHNew, false));
		}

		internal bool GetPipeRadius(string strPipeText, out double dRadius)
		{
			dRadius = -1.0;
			StringBuilder stringBuilder = new StringBuilder();
			bool result;
			try
			{
				foreach (char c in strPipeText.ToCharArray())
				{
					if (this.IsNumberic(c))
					{
						stringBuilder.Append(c);
					}
				}
				result = double.TryParse(stringBuilder.ToString(), out dRadius);
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}

		private bool IsNumberic(char chText)
		{
			bool result;
			try
			{
				if (chText < '0' || chText > '9')
				{
					result = false;
				}
				else
				{
					result = true;
				}
			}
			catch (Exception)
			{
				result = false;
			}
			return result;
		}

		private void ReadPipeDWGDataSettingForm_KeyPress(object sender, KeyPressEventArgs e)
		{
			bool flag = this.btnPickTwoLine.Enabled || this.btnStartPt.Enabled;
			if (this.rdoTextLayer.Checked)
			{
				if (flag && this.btnPickPipe.Enabled && this.btnPickUpperSprayer.Enabled && this.btnPickLowerSprayer.Enabled && this.btnPickPipeSizeMarkedText.Enabled && e.KeyChar == '\u001b')
				{
					base.Close();
					return;
				}
			}
			else if (flag && this.btnMainPipeSelection.Enabled && this.btnPickPipe.Enabled && this.btnPickUpperSprayer.Enabled && this.btnPickLowerSprayer.Enabled && e.KeyChar == '\u001b')
			{
				base.Close();
			}
		}

		private void rdoByTwoLine_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoByTwoLine.Checked)
			{
				this.btnPickTwoLine.Enabled = true;
				this.btnStartPt.Enabled = false;
			}
		}

		private void rdoByPickPoint_CheckedChanged(object sender, EventArgs e)
		{
			if (this.rdoByPickPoint.Checked)
			{
				this.btnPickTwoLine.Enabled = false;
				this.btnStartPt.Enabled = true;
			}
		}

		private void ReadPipeDWGDataSettingForm_ResizeBegin(object sender, EventArgs e)
		{
			this.MinimumSize = new Size(Convert.ToInt32((double)this.m_nWidth * this.m_dWCoefficient), Convert.ToInt32((double)this.m_nHeight * this.m_dHCoefficient));
		}

		private void ReadPipeDWGDataSettingForm_ResizeEnd(object sender, EventArgs e)
		{
			this.pbxWH.Tag = this.m_nWidth + "," + this.m_nHeight;
			this.pbxWHNew.Tag = base.Width + "," + base.Height;
		}

		private int m_nWidth;

		private int m_nHeight;

		private double m_dWCoefficient = 0.6;

		private double m_dHCoefficient = 0.92;

		private OdDbEntity m_layerTR;

		private Document m_doc;

		private string m_OdDbDataBasePath;

		private static bool m_b;

		private DwgPreview m_view;

		private static OdDbDatabase m_database;

		private CADData m_CADData = new CADData();

		private string m_strPipeStart = string.Empty;

		private string m_strPipeLine = string.Empty;

		private string m_strPipeLayer = string.Empty;

		private string m_strUpNozzle = string.Empty;

		private string m_strLowNozzle = string.Empty;

		private string m_strDimLayer = string.Empty;

		private XYZEqualityComparer useXYZComparer = new XYZEqualityComparer();

		private FrmDefineSprayPipeDiameter m_frmDefineSprayPipeDiameter;

		private ControlInfoManager m_ControlInfoManager;

		private List<KeyValuePair<System.Windows.Forms.Control, bool>> m_lstControlGroup = new List<KeyValuePair<System.Windows.Forms.Control, bool>>();

		private bool m_isLinkDWG;

		public static bool m_isSameName;

		public static EnumGetNozzleLayerType m_GetmNozzleLayerType;

		private XYZ m_BasePoint;

		private OdDbEntity m_dbPipeEntity;

		private List<OdDbObjectId> m_lstMainPipeSelectionObjectId = new List<OdDbObjectId>();

		private OdDbEntity m_dbDimensionEntity;

		private OdDbEntity m_dbUpperSprayerEntity;

		private OdDbEntity m_dbLowerSprayerEntity;

		private List<OdDbCircle> m_lstCircleDrawable = new List<OdDbCircle>();
	}
}
